Skip to content

Resolve POSIX adapter paths against the base path - #13

Closed
jamiecounsell wants to merge 2 commits into
attermann:masterfrom
zerokelvin-dev:posix-basepath
Closed

jamiecounsell wants to merge 2 commits into
attermann:masterfrom
zerokelvin-dev:posix-basepath

Conversation

@jamiecounsell

Copy link
Copy Markdown

Note: this PR is stacked on #12

The POSIX adapter took a base path parameter but ignored it (outside ESP32's LittleFS.begin()), so relative store paths like ./known_store/ resolved against the working directory. On ESP-IDF there is no working directory, so these paths never resolved. The adapter also kept the caller's pointer, which dangles if the string was only temporary.

Now, the adapter keeps its own copy of the base path and resolves future relative paths against it. Absolute paths, and everything when the base path is empty (the default), remain unchanged.

The stdio adapter has the same unused base path. I left it alone to keep this change to one adapter.

Testing: pio test -e native: the new base-path tests pass and fail without the fix. The same three test_file_store tests fail as on master. heltec_wifi_lora_32_V3 builds the adapter with -DUSTORE_USE_POSIXFS. Running in SolarOS on the M9 as the store backend for microReticulum.

jamiecounsell and others added 2 commits October 25, 2026 12:49
rmdir() in the POSIX and stdio adapters returned false when the directory
was removed and true when it wasn't, the opposite of every other adapter
(and of mkdir()).

Adds test/test_posix_fs, which runs the adapters against a real temp
directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rUgoKJdB4U8fNS9HybY8S
The POSIX adapter took a base path but ignored it (outside ESP32's
LittleFS.begin()), so relative store paths like ./known_store/ resolved
against the working directory. On ESP-IDF there is no working directory,
so these paths never resolved. The adapter also kept the caller's pointer,
which dangles if the string was only temporary.

The adapter now keeps its own copy of the base path and resolves relative
paths against it. Absolute paths, and everything when the base path is
empty (the default), are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rUgoKJdB4U8fNS9HybY8S
@attermann

Copy link
Copy Markdown
Owner

Thanks for this, and for the tests and the detailed write-up. The problems you found are real: the POSIX adapter ignores its base path, relative store paths have nothing to resolve against on ESP-IDF, and the adapter holds on to the caller's pointer. They need fixing.

I'm going to close this PR, though, because I don't think the fix should be made one adapter at a time. There are two reasons:

  • It only fixes PosixFileSystem. StdioFileSystem has the same unused base path and the same borrowed pointer, so the adapters would end up interpreting the base path differently.
  • It makes absolute paths skip the base path. That's the opposite of what the ESP32 VFS-backed adapters already do: Arduino's VFSImpl (framework-arduinoespressif32/libraries/FS/src/vfs_api.cpp) puts the mount point in front of every path and rejects any path that doesn't start with /. Under that model a path like /store lands inside the base path. With this change it would skip it.

The right fix is a single path model shared by every adapter, so a store path means the same thing whichever adapter is underneath. I'll fix it that way. Your ESP-IDF case (no working directory, relative store paths) is a good test for it.

Thanks again for digging into this.

@attermann attermann closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants